﻿<UserControl x:Class="GSF.TimeSeries.UI.UserControls.AdvancedSearchUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:GSF.TimeSeries.UI.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBoxItem">
                            <Border Name="Border" SnapsToDevicePixels="true" Background="White" Margin="0">
                                <ContentPresenter/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                                    <Setter TargetName="Border" Property="Background" Value="#FFDEE7EE"/>
                                </Trigger>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter TargetName="Border" Property="Background" Value="LightBlue"/>
                                    <Setter TargetName="Border" Property="BorderBrush" Value="#FF9EA7BF"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <TabControl Grid.Row="0" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType=UserControl}}">
        <TabItem Header="Search">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Orientation="Horizontal">
                    <Label Content="Search text:" />
                    <TextBox Text="{Binding Mode=TwoWay, Path=SearchText}" VerticalAlignment="Top" />
                </StackPanel>

                <CheckBox Grid.Row="1" Content="Ignore Case" IsChecked="{Binding Mode=TwoWay, Path=IgnoreCase}" />
                <CheckBox Grid.Row="2" Content="Use Wildcards" IsChecked="{Binding Mode=TwoWay, Path=UseWildcards}" IsEnabled="{Binding Path=UseRegex, Converter={StaticResource NotConverter}}" />
                <CheckBox Grid.Row="3" Content="Use Regex" IsChecked="{Binding Mode=TwoWay, Path=UseRegex}" />
            </Grid>
        </TabItem>
        <TabItem Header="Categories">
            <ListBox Name="CategoriesListBox" ItemsSource="{Binding Categories}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <CheckBox Margin="5,0,0,0" Content="{Binding Path=Name}" IsChecked="{Binding Mode=TwoWay, Path=Selected}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </TabItem>
    </TabControl>
</UserControl>
